package com.example.idachuappone.index.dto;

import android.content.Context;
import com.example.idachuappone.R;
import com.example.idachuappone.index.welcomentity.Welcome;
import org.json.JSONObject;

public class WelcomeDto {
    public Welcome getWelcome(Context context, String json) throws Exception {
        try {
            JSONObject jsonObject = new JSONObject(json);
            if (jsonObject.getInt("code") == 10000) {
                Welcome welcome = new Welcome();
                welcome.parseJson(jsonObject.getJSONObject("data"));
                return welcome;
            }
            throw new Exception(jsonObject.getString("error"));
        } catch (Exception e) {
            e.printStackTrace();
            throw new Exception(context.getResources().getString(R.string.app_error));
        }
    }
}
